import App from "./App";

// #ifndef VUE3
import Vue from "vue";
import "./uni.promisify.adaptor";
import "@/static/font_icon/iconfont.css";

import axios from "./ulit/axios.js";
import getLoginInfo from "./ulit/getLoginInfo.js";
import sendMessage from "./ulit/sendMessage.js";
import getFileExtensionName from "./ulit/getFileExtensionName.js";
import showToast from "./ulit/showToast.js";
Vue.prototype.$axios = axios;
Vue.prototype.$getLoginInfo = getLoginInfo;
Vue.prototype.$sendMessage = sendMessage;
Vue.prototype.$getFileExtensionName = getFileExtensionName;
Vue.prototype.$showToast = showToast;

// 路由跳转
Vue.prototype.$router = (to) => {
	uni.navigateTo({
		url: to,
	});
};

Vue.prototype.$getTime = function(format, time) {
	let date;
	if (time) {
		date = new Date(time)
	} else {
		date = new Date()
	}
	let year = date.getFullYear()
	let month = (date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)
	let day = date.getDate() >= 10 ? date.getDate() : '0' + (date.getDate())
	let h = date.getHours() >= 10 ? date.getHours() : '0' + (date.getHours())
	let m = date.getMinutes() >= 10 ? date.getMinutes() : '0' + (date.getMinutes())
	let s = date.getSeconds() >= 10 ? date.getSeconds() : '0' + (date.getSeconds())

	// 默认显示年月日
	if (format == 'yyyy-MM-DD') {
		return year + '-' + month + '-' + day
	} else if (format == 'yyyy-MM') {
		return year + '-' + month
	} else {
		return year + '-' + month + '-' + day + " " + h + ":" + m + ":" + s
	}
}


Vue.config.productionTip = false;
App.mpType = "app";
const app = new Vue({
	...App,
});
app.$mount();
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from "vue";
export function createApp() {
	const app = createSSRApp(App);
	return {
		app,
	};
}
// #endif